package com.yilin.tms.core.entity.message;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yilin.tms.core.commons.annotation.Explain;
import com.yilin.tms.core.entity.user.UserType;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.io.Serializable;
import java.util.Date;

/**
 * 聊天记录类 mongoDB
 *
 * @author zhangjinyuan
 * @date 2022/10/26
 */
@Document("message_data")//指定数据库中的集合（相当于mysql中的表）
public class MessageData implements Serializable {

    /**
     * 消息类型
     */
    public enum MessageType {
        chat(0, "聊天"),
        notice(1, "通知"),
        order(2, "订单");

        @EnumValue
        public Integer index;
        public String name;

        MessageType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 数据类型
     */
    public enum DataType {
        text(0,"文本数据"),
        image(1,"图片数据"),
        voice(2,"语音数据"),
        video(3,"视频数据"),
        file(4,"文件数据"),
        order(5,"订单数据");

        @EnumValue
        public Integer index;
        public String name;

        DataType(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 发送状态
     */
    public enum SendState {
        draft(0,"草稿"),
        upload(1,"待上传"),
        wait(2,"已保存本地 待发送"),
        send(3,"已发送成功"),
        fail(4,"发送失败 处理为离线"),
        receive(5,"已接收"),
        read(6,"已查看");

        @EnumValue
        public Integer index;
        public String name;

        SendState(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /**
     * 显示状态
     */
    public enum ViewState {
        view(0,"显示"),
        revoke(1,"撤销"),
        delete(2,"删除");

        @EnumValue
        public Integer index;
        public String name;

        ViewState(Integer index, String name) {
            this.index = index;
            this.name = name;
        }
    }

    /*
    基础信息
     */
    @Id
    @Explain("ID")
    private String id;
    // 客户端数据库唯一标识
    private String sId;
    @Explain("消息类型")
    private MessageType messageType;
    @Explain("数据类型")
    private DataType dataType;
    @Explain("发送状态")
    private SendState sendState;
    @Explain("显示状态")
    private ViewState viewState;
    //消息文本，语音显示时长(`s)，图片显示缩略图(300x)，视频显示封面图(300x),文件名，订单处理提示
    @Explain("消息内容")
    private String text;
    //原始数据 图片Url/视频Url/文件地址/订单链接
    @Explain("原始数据")
    private String originalUrl;

    /*
    创建人 ---通知显示为系统
     */
    @Explain("创建人id")
    private String accountId;
    @Explain("创建人类型")
    private UserType accountUserType;
    @Explain("创建人头像")
    private String accountAvatar;
    @Explain("创建人名")
    private String accountName;

    /*
    收件人
     */
    @Explain("接受人id")
    private String toAccountId;
    @Explain("接受人类型")
    private UserType toAccountUserType;
    @Explain("接受人头像")
    private String toAccountAvatar;
    @Explain("接受人名")
    private String toAccountName;

    /*
    时间节点
     */
    @Explain("消息发送时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date sendTime;
    @Explain("消息接收时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date receiveTime;
    @Explain("消息阅读时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date readTime;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getsId() {
        return sId;
    }

    public void setsId(String sId) {
        this.sId = sId;
    }

    public MessageType getMessageType() {
        return messageType;
    }

    public void setMessageType(MessageType messageType) {
        this.messageType = messageType;
    }

    public DataType getDataType() {
        return dataType;
    }

    public void setDataType(DataType dataType) {
        this.dataType = dataType;
    }

    public SendState getSendState() {
        return sendState;
    }

    public void setSendState(SendState sendState) {
        this.sendState = sendState;
    }

    public ViewState getViewState() {
        return viewState;
    }

    public void setViewState(ViewState viewState) {
        this.viewState = viewState;
    }

    public String getText() {
        return text;
    }

    public void setText(String text) {
        this.text = text;
    }

    public String getOriginalUrl() {
        return originalUrl;
    }

    public void setOriginalUrl(String originalUrl) {
        this.originalUrl = originalUrl;
    }

    public String getAccountId() {
        return accountId;
    }

    public void setAccountId(String accountId) {
        this.accountId = accountId;
    }

    public UserType getAccountUserType() {
        return accountUserType;
    }

    public void setAccountUserType(UserType accountUserType) {
        this.accountUserType = accountUserType;
    }

    public String getAccountAvatar() {
        return accountAvatar;
    }

    public void setAccountAvatar(String accountAvatar) {
        this.accountAvatar = accountAvatar;
    }

    public String getAccountName() {
        return accountName;
    }

    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    public String getToAccountId() {
        return toAccountId;
    }

    public void setToAccountId(String toAccountId) {
        this.toAccountId = toAccountId;
    }

    public UserType getToAccountUserType() {
        return toAccountUserType;
    }

    public void setToAccountUserType(UserType toAccountUserType) {
        this.toAccountUserType = toAccountUserType;
    }

    public String getToAccountAvatar() {
        return toAccountAvatar;
    }

    public void setToAccountAvatar(String toAccountAvatar) {
        this.toAccountAvatar = toAccountAvatar;
    }

    public String getToAccountName() {
        return toAccountName;
    }

    public void setToAccountName(String toAccountName) {
        this.toAccountName = toAccountName;
    }

    public Date getSendTime() {
        return sendTime;
    }

    public void setSendTime(Date sendTime) {
        this.sendTime = sendTime;
    }

    public Date getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(Date receiveTime) {
        this.receiveTime = receiveTime;
    }

    public Date getReadTime() {
        return readTime;
    }

    public void setReadTime(Date readTime) {
        this.readTime = readTime;
    }

}
